package com.zr.daoimpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Iterator;
import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.zr.dao.OrderTypeDaoLPN;
import com.zr.model.Function;
import com.zr.model.Ordertype;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Repository("otDao")
public class OrderTypeDaoImplLPN extends BaseDaOImpl implements OrderTypeDaoLPN{

	@Override
	public JSONArray findOT() {
		JSONArray j = new JSONArray();
		String hql = " from Ordertype ot";
		Query query = this.getCurrentSession().createQuery(hql);
		List<Ordertype>  obj = query.list();	
		Iterator<Ordertype> it = obj.iterator();
		while(it.hasNext()) {
			JSONObject js=new JSONObject();
			Ordertype o=it.next();
			js.put("otId",o.getOtId());
			js.put("otName", o.getOtName());
			j.add(js);					  
		}		
		return j;
	}
}

